package cn.scw.project.facility.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.aspectj.lang.annotation.Log;
import cn.scw.framework.aspectj.lang.enums.BusinessType;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.facility.domain.FacPrintType;
import cn.scw.project.facility.domain.netework.bean.FacPrintTypeAddReq;
import cn.scw.project.facility.service.IFacPrintTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 打印类型Controller
 *
 * @author api
 * @date 2020-06-02
 */
@Api(tags = "打印类型")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH+"/facility/type")
public class FacPrintTypeController extends BaseController {
    @Autowired
    private IFacPrintTypeService facPrintTypeService;

    @ApiOperation("查询打印类型列表")
    //@PreAuthorize("@ss.hasPermi('facility:type:list')")
    @GetMapping("/list")
    public TableDataInfo list( ) {
        startPage();
        List<FacPrintType> list = facPrintTypeService.selectFacPrintTypeList();
        return getDataTable(list);
    }

    @ApiOperation("获取打印类型详细信息")
    //@PreAuthorize("@ss.hasPermi('facility:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(facPrintTypeService.selectFacPrintTypeById(id));
    }


    @ApiOperation("新增打印类型")
    //@PreAuthorize("@ss.hasPermi('facility:type:add')")
    @Log(title = "打印类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(FacPrintTypeAddReq req) {
        return toAjax(facPrintTypeService.insertFacPrintType(req));
    }

    @ApiOperation("修改打印类型")
    //@PreAuthorize("@ss.hasPermi('facility:type:edit')")
    @Log(title = "打印类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(FacPrintTypeAddReq facPrintType) {
        return toAjax(facPrintTypeService.updateFacPrintType(facPrintType));
    }

    @ApiOperation("删除打印类型")
    //@PreAuthorize("@ss.hasPermi('facility:type:remove')")
    @Log(title = "打印类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(facPrintTypeService.deleteFacPrintTypeByIds(ids));
    }
}
